<template>
  <div class="acthorizing">
    <!-- <img src="" alt=""> -->
    <!-- <h3 class="acthorizing_h3">企点授权页面</h3> -->
    <p class="acthorizing_p">此页面是企点授权页面，点击下方按钮弹出授权页面或者跳转页面</p>
    <button open-type="getUserInfo" class='acthorizing_button' lang="zh_CN" bindgetuserinfo="onGotUserInfo">获取用户信息</button>
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'
export default {
  data () {
    return {
      motto: 'Hello World',
      clear: ''
    }
  },
  components: {
  },
  onShow () {
    let clear = setInterval(() => {
      this.getSetting()
    }, 300)
    this.clear = clear
  },
  onHide () {
    clearInterval(this.clear)
  },
  created () {
  },
  computed: {
    ...mapGetters({
      authSetting: 'getAuthSetting'
    })
  },
  methods: {
    ...mapActions([
      'updateAuthSetting'
    ]),
    // 获取用户权限
    getSetting () {
      wx.getSetting({
        success: (res) => {
          if (res.authSetting['scope.userInfo']) {
            wx.navigateBack({
              delta: 1
            })
          }
        },
        fail: (res) => {}
      })
    }
  }
}
</script>

<style>
  .acthorizing{
    text-align: center;
  }
  .acthorizing_p{
    font-size: 16px;
    color:#ccc;
    margin: 300px 40px 0px;
  }
  .acthorizing_button{
    margin: 60px 60px 0;
    color:#17d540;
    font-size:18px;
    border:1px solid #bff5cb;
  }
</style>
